package com.iflyun.LogsCustmerToHDFS.dao.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.alibaba.fastjson.JSON;
import com.iflyun.LogsCustmerToHDFS.common.Common;
import com.iflyun.LogsCustmerToHDFS.dao.ApiLogDao;
import com.iflyun.LogsCustmerToHDFS.entity.CallLog;
import com.iflyun.LogsCustmerToHDFS.utils.HdfsUtils;

/**
 * 
 * @ClassName:  ApiLogDaoImpl   
 * @Description:api接口日志持久层实现
 * @author: wenquxing  
 * @date:   2017年8月25日 上午10:46:21   
 *
 */
@Repository
public class ApiLogDaoImpl implements ApiLogDao {
	
	private static final Logger logger = LoggerFactory.getLogger(ApiLogDaoImpl.class);

	@Override
	public List<CallLog> setApiLogList(List<CallLog> list,String day) {
		String str=JSON.toJSONString(list);
		try {
			HdfsUtils.createOrAppend(str, Common.hdfs, day,"api");
		} catch (Exception e) {
			logger.error("写入HDFS报错",e);
		} 
		list.clear();
		return list;
	}

}
